package com.ken.mall.comm;

import org.apache.commons.lang3.StringUtils;

public class Const {

    public static final String CURRENT_USER = "currentUser";

    public static final String EMAIL = "email";

    public static final String USERNAME = "username";

    public static final String WX_OPEN_ID = "wxOpenId";

    public static final String SERVICE_MESSAGE = "NICK_NAME 您好，您预约的SERVICE_CATEGORY_NAME 已在受理中，请您耐心等待并保持手机畅通。如需帮助请致电：400-021-1717";

    public interface RedisCacheExtime{
        int REDIS_SESSION_EXTIME = 60 * 30;//30分钟
    }
    public interface Role{
        int ROLE_CUSTOMER = 0;
        int ROLE_ADMIN = 1;
    }

    public interface Cart{
        int CHECKED = 1;//购物车选中状态
        int UN_CHECKED = 0;//购物车未选中状态

        String LIMIT_NUM_FAIL = "LIMIT_NUM_FAIL";
        String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS";
    }

    public interface ProductStatus{
        int ON_SALE = 1;
        int UN_SALE = 0;
    }

    public enum OrderStatusEnum{
        CANCELED(0,"已取消"),
        NO_PAY(10,"待付款"),
        PAID(20,"已付款"),
        PENDING(30,"待受理"),
        SHIPPED(40,"已受理"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭");

        OrderStatusEnum(int code,String value){
            this.code = code;
            this.value = value;
        }
        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static OrderStatusEnum codeOf(int code){
            for(OrderStatusEnum orderStatusEnum : values()){
                if(orderStatusEnum.getCode() == code){
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("么有找到对应的枚举");
        }
    }

    public enum BrowserPlatFlagEnum{
        ALI_BROWSER("AlipayClient","支付宝访问的报文关键字"),
        WX_BROWSER("MicroMessenger","微信访问的报文关键字");
        private String userAgent;
        private String desc;

        BrowserPlatFlagEnum(String userAgent, String desc) {
            this.userAgent = userAgent;
            this.desc = desc;
        }

        public String getUserAgent() {
            return userAgent;
        }

        public void setUserAgent(String userAgent) {
            this.userAgent = userAgent;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }

    public interface WxPayCallBack{
        String RETURN_CODE = "SUCCESS";
        String RESULT_CODE = "SUCCESS";
    }

    public enum  PayPlatforEnum{
        ALI_NATIVE_PAY(1,"","支付宝扫码支付"),
        WX_MWEB_PAY(2,"MWEB","微信H5支付"),
        WX_APP_PAY(3,"APP","微信App支付"),
        WX_JSAPI_PAY(4,"JSAPI","微信公众号支付"),
        WX_NATIVE_PAY(5,"NATIVE","微信扫码支付");
        private int code;
        private String type;
        private String desc;

        PayPlatforEnum(int code, String type, String desc) {
            this.code = code;
            this.type = type;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public static PayPlatforEnum codeOf(int code){
            for (PayPlatforEnum payPlatforEnum : values()){
                if (payPlatforEnum.getCode() ==code){
                    return payPlatforEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }

        public static PayPlatforEnum typeOf(String type){
            for (PayPlatforEnum payPlatforEnum : values()){
                if (StringUtils.equals(payPlatforEnum.getType(),type)){
                    return payPlatforEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }

    public enum PaymentTypeEnum{
        ONLINE_PAY(1,"在线"),
        UNLINE_PAY(2,"线下");
        private int code;
        private String value;
        PaymentTypeEnum(int code,String value){
            this.code = code;
            this.value = value;
        }

        public int getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }

        public static PaymentTypeEnum codeOf(int code){
            for (PaymentTypeEnum paymentTypeEnum : values()){
                if (paymentTypeEnum.getCode() ==code){
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }

    public interface WxApi{
        /** 获取微信用户授权token*/
        String ACCREDIT_TOKEN_URL="https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";

    }


}
